package com.fcscs.cservice.domain.validator;

import com.fcscs.core.common.ErrorEnums;
import com.fcscs.core.common.FieldValidators;
import com.fcscs.core.domain.validator.BaseValidator;
import com.fcscs.cservice.domain.Country;
import com.fcscs.cservice.domain.FieldEditability;
import com.fcscs.cservice.domain.Language;
import com.fcscs.cservice.domain.Nationality;
import com.fcscs.cservice.domain.NotifDestination;
import com.fcscs.cservice.domain.NotifTemplate;
import com.fcscs.cservice.domain.PaymentMethod;
import com.fcscs.cservice.domain.PropertyConfiguration;
//import com.fcscs.cservice.domain.ReservationStatus;
import com.fcscs.cservice.domain.RoomStatus;
import com.fcscs.cservice.domain.State;
import com.fcscs.cservice.domain.Title;

public interface CServiceCommonValidators {
	
	public static class PropertyConfValidator extends BaseValidator<PropertyConfiguration> {
		public ErrorEnums validate(PropertyConfiguration entity, boolean newInstance) {
			ErrorEnums err = super.validate(entity, newInstance);
			if (err != null) {
				return err;
			} else {
				if (/*FieldValidators.isNullEmptyStr(entity.getGsa()) || FieldValidators.isNullEmptyStr(entity.getSpg())
						|| FieldValidators.isNullEmptyStr(entity.getTandc()) || entity.getPropertyId() <= 0
						||*/ entity.getBookingSearchDays() < 0 || entity.getReservationSearchDays() < 0
						|| entity.getCiReqTimeout() < 0 || entity.getCoReqTimeout() < 0) {
					return ErrorEnums.GeneralError.REQURIED_FLD_MISSING;
				}
			}
			return null;
		}
	}
	
	public static class CountryValidator extends BaseValidator<Country> {
		public ErrorEnums validate(Country entity, boolean newInstance) {
			ErrorEnums err = super.validate(entity, newInstance);
			if (err != null) {
				return err;
			} else {
				if (FieldValidators.isNullEmptyStr(entity.getCountry())) {
					return ErrorEnums.GeneralError.REQURIED_FLD_MISSING;
				}
			}
			return null;
		}
	}

	public static class StateValidator extends BaseValidator<State> {
		public ErrorEnums validate(State entity, boolean newInstance) {
			ErrorEnums err = super.validate(entity, newInstance);
			if (err != null) {
				return err;
			} else {
				if (FieldValidators.isNullEmptyStr(entity.getState())) {
					return ErrorEnums.GeneralError.REQURIED_FLD_MISSING;
				}
			}
			return null;
		}
	}

	public static class TitleValidator extends BaseValidator<Title> {
		public ErrorEnums validate(Title entity, boolean newInstance) {
			ErrorEnums err = super.validate(entity, newInstance);
			if (err != null) {
				return err;
			} else {
				if (FieldValidators.isNullEmptyStr(entity.getTitle())) {
					return ErrorEnums.GeneralError.REQURIED_FLD_MISSING;
				}
			}
			return null;
		}
	}

	public static class NationalityValidator extends BaseValidator<Nationality> {
		public ErrorEnums validate(Nationality entity, boolean newInstance) {
			ErrorEnums err = super.validate(entity, newInstance);
			if (err != null) {
				return err;
			} else {
				if (FieldValidators.isNullEmptyStr(entity.getNationality())) {
					return ErrorEnums.GeneralError.REQURIED_FLD_MISSING;
				}
			}
			return null;
		}
	}

	public static class LanguageValidator extends BaseValidator<Language> {
		public ErrorEnums validate(Language entity, boolean newInstance) {
			ErrorEnums err = super.validate(entity, newInstance);
			if (err != null) {
				return err;
			} else {
				if (FieldValidators.isNullEmptyStr(entity.getLanguage())) {
					return ErrorEnums.GeneralError.REQURIED_FLD_MISSING;
				}
			}
			return null;
		}
	}

	public static class PayMethodValidator extends BaseValidator<PaymentMethod> {
		public ErrorEnums validate(PaymentMethod entity, boolean newInstance) {
			ErrorEnums err = super.validate(entity, newInstance);
			if (err != null) {
				return err;
			} else {
				if (FieldValidators.isNullEmptyStr(entity.getMethod())) {
					return ErrorEnums.GeneralError.REQURIED_FLD_MISSING;
				}
			}
			return null;
		}
	}

	public static class RoomStatusValidator extends BaseValidator<RoomStatus> {
		public ErrorEnums validate(RoomStatus entity, boolean newInstance) {
			ErrorEnums err = super.validate(entity, newInstance);
			if (err != null) {
				return err;
			} else {
				if (FieldValidators.isNullEmptyStr(entity.getRoomStatus()) || FieldValidators.isNullEmptyStr(entity.getColorCode())) {
					return ErrorEnums.GeneralError.REQURIED_FLD_MISSING;
				}
			}
			return null;
		}
	}

/*	public static class RsvStatusValidator extends BaseValidator<ReservationStatus> {
		public ErrorEnums validate(ReservationStatus entity, boolean newInstance) {
			ErrorEnums err = super.validate(entity, newInstance);
			if (err != null) {
				return err;
			} else {
				if (FieldValidators.isNullEmptyStr(entity.getStatus())) {
					return ErrorEnums.GeneralError.REQURIED_FLD_MISSING;
				}
			}
			return null;
		}
	}*/

	public static class FieldEditabilityValidator extends BaseValidator<FieldEditability> {
		public ErrorEnums validate(FieldEditability entity, boolean newInstance) {
			ErrorEnums err = super.validate(entity, newInstance);
			if (err != null) {
				return err;
			} else {
				if (entity.getCategoryEnum() == null || entity.getFieldEnum() == null) {
					return ErrorEnums.GeneralError.REQURIED_FLD_MISSING;
				}
				if (!entity.getCategoryEnum().getFieldList().contains(entity.getFieldEnum())) {
					return ErrorEnums.GeneralError.NAME_UNIQUE_CONS;
				}
			}
			return null;
		}
	}

	public static class NotifDestinationValidator  extends BaseValidator<NotifDestination> {
		public ErrorEnums validate(NotifDestination entity, boolean newInstance) {
			ErrorEnums err = super.validate(entity, newInstance);
			if (err != null) {
				return err;
			} else {
				if (entity.getNotifTypeEnum() == null /*|| entity.getDestTypeEnum() == null || FieldValidators.isNullEmptyStr(entity.getDestination())*/) {
					return ErrorEnums.GeneralError.REQURIED_FLD_MISSING;
				}
			}
			return null;
		}
	}

	public static class NotifTemplateValidator  extends BaseValidator<NotifTemplate> {
		public ErrorEnums validate(NotifTemplate entity, boolean newInstance) {
			ErrorEnums err = super.validate(entity, newInstance);
			if (err != null) {
				return err;
			} else {
				if (entity.getTmplTypeEnum() == null /*|| FieldValidators.isNullEmptyStr(entity.getTitle()) || FieldValidators.isNullEmptyStr(entity.getDetail())*/) {
					return ErrorEnums.GeneralError.REQURIED_FLD_MISSING;
				}
			}
			return null;
		}
	}
}
